#include "unp.h"

void dg_echo(int fd, struct sockaddr *cliaddr, socklen_t clilen)
{
    ssize_t n;
    socklen_t len;
    char buf[MAXLINE];
    int i = 0;

    while (1) {
        len = clilen;
        n = Recvfrom(fd, buf, MAXLINE, 0, cliaddr, &len);
        if (i++ == 0) {
            printf("len=%d, clilen=%d\n", len, clilen);
        }
        Sendto(fd, buf, n, 0, cliaddr, len);
    }
}
